package com.itheima.proxy.jdk;

import sun.misc.ProxyGenerator;

import java.lang.reflect.Proxy;

/**
 * @program: design
 * @description:
 * @author: zhanghz001
 * @create: 2020-11-26 16:59
 **/
public class JdkProxyTest {
    public static void main(String[] args) {
        //被创建代理的对象
        LandlordService service = new Landlord();
        //
        //这个代理是接口代理
        LandlordService serviceProxy =
                (LandlordService) Proxy.newProxyInstance(
                        service.getClass().getClassLoader(),
                        //这个用的好,被代理的接口
                        Landlord.class.getInterfaces(),
                        new QFang(service));
        serviceProxy.pay("王五");
        //
        byte[] proxyClass = ProxyGenerator.generateProxyClass(
                serviceProxy.getClass().getSimpleName(),
                serviceProxy.getClass().getInterfaces());
        //

    }
}
